package com.chub.study.modules.entity;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 日志表
 * </p>
 *
 * @author Chub
 * @since 2022-11-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_log")
@ApiModel(value="TLog", description="日志表")
public class TLog implements Serializable {

    private static final long serialVersionUID = 1L;

    // ASSIGN_ID（雪花算法）
    // 如果不设置类型值，默认则使用IdType.ASSIGN_ID策略（自3.3.0起）。该策略会使用雪花算法自动生成主键ID，主键类型为长或字符串（分别对应的MySQL的表字段为BIGINT和VARCHAR）
    // 提示：该策略使用接口IdentifierGenerator的方法nextId（以实现类为DefaultIdentifierGenerator雪花算法），下面是雪花算法介绍：
    //
    // 雪花算法（雪花）是微博开源的分布式ID生成算法其核心思想就是：使用一个64位的长型的数字作为全局唯一ID。在分布式系统中的应用十分广泛，且ID引入了时间戳，基本上保持自增的。
    @ApiModelProperty(value = "日志UUID")
    @TableId(value = "LOG_ID")
    private String logId;

    @ApiModelProperty(value = "报文UUID")
    @TableField("MSG_ID")
    private String msgId;

    @ApiModelProperty(value = "发起渠道编号")
    @TableField("SEND_CHNL_CODE")
    private String sendChnlCode;

    @ApiModelProperty(value = "发起渠道名称")
    @TableField("SEND_CHNL_NAME")
    private String sendChnlName;

    @ApiModelProperty(value = "发起方流水号")
    @TableField("SEND_SRL_NUM")
    private String sendSrlNum;

    @ApiModelProperty(value = "发起时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    @TableField("SEND_TIME")
    private LocalDateTime sendTime;

    @ApiModelProperty(value = "交易代码")
    @TableField("TRAN_CODE")
    private String tranCode;

    @ApiModelProperty(value = "交易名称")
    @TableField("TRAN_NAME")
    private String tranName;

    @ApiModelProperty(value = "日志级别(0-debug, 1-info, 2-warn, 3-error)")
    @TableField("LOG_LEVEL")
    private String logLevel;

    @ApiModelProperty(value = "日志内容")
    @TableField("LOG_CONTENT")
    private String logContent;

    @ApiModelProperty(value = "创建人")
    @TableField("CRT_USER")
    private String crtUser;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "CRT_TIME", fill = FieldFill.INSERT)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private Date crtTime;

    @ApiModelProperty(value = "更新人")
    @TableField("UPT_USER")
    private String uptUser;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    @TableField(value = "UPT_TIME", fill = FieldFill.INSERT_UPDATE)
    private Date uptTime;


}
